package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAOwnersList;
import com.ruoyi.system.service.ISysAOwnersListService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业委会管理Controller
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/owners")
public class SysAOwnersListController extends BaseController
{
    private String prefix = "system/owners";

    @Autowired
    private ISysAOwnersListService sysAOwnersListService;

    @RequiresPermissions("system:owners:view")
    @GetMapping()
    public String owners()
    {
        return prefix + "/owners";
    }

    /**
     * 查询业委会管理列表
     */
    @RequiresPermissions("system:owners:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysAOwnersList sysAOwnersList)
    {
        startPage();
        List<SysAOwnersList> list = sysAOwnersListService.selectSysAOwnersListList(sysAOwnersList);
        return getDataTable(list);
    }

    /**
     * 导出业委会管理列表
     */
    @RequiresPermissions("system:owners:export")
    @Log(title = "业委会管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysAOwnersList sysAOwnersList)
    {
        List<SysAOwnersList> list = sysAOwnersListService.selectSysAOwnersListList(sysAOwnersList);
        ExcelUtil<SysAOwnersList> util = new ExcelUtil<SysAOwnersList>(SysAOwnersList.class);
        return util.exportExcel(list, "业委会管理数据");
    }

    /**
     * 新增业委会管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存业委会管理
     */
    @RequiresPermissions("system:owners:add")
    @Log(title = "业委会管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysAOwnersList sysAOwnersList)
    {
        return toAjax(sysAOwnersListService.insertSysAOwnersList(sysAOwnersList));
    }

    /**
     * 修改业委会管理
     */
    @GetMapping("/edit/{ownersId}")
    public String edit(@PathVariable("ownersId") Long ownersId, ModelMap mmap)
    {
        SysAOwnersList sysAOwnersList = sysAOwnersListService.selectSysAOwnersListByOwnersId(ownersId);
        mmap.put("sysAOwnersList", sysAOwnersList);
        return prefix + "/edit";
    }

    /**
     * 修改保存业委会管理
     */
    @RequiresPermissions("system:owners:edit")
    @Log(title = "业委会管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysAOwnersList sysAOwnersList)
    {
        return toAjax(sysAOwnersListService.updateSysAOwnersList(sysAOwnersList));
    }

    /**
     * 删除业委会管理
     */
    @RequiresPermissions("system:owners:remove")
    @Log(title = "业委会管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysAOwnersListService.deleteSysAOwnersListByOwnersIds(ids));
    }
}
